# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html

from baiduNewsSpider.models import NewsType
class ElastisearchPipeline(object):
    def process_item(self, item, spider):
        if spider.name == 'newsspider':  # 如果是新闻爬虫，存到elasticsearch中
            news = NewsType()
            news.title = item['title']
            news.content = item['content']

            news.save()
        return item
